//工厂模式
// 产品接口
interface Product {
    void use();
}

// 具体产品类A
class ConcreteProductA implements Product {
    public void use() {
        System.out.println("Using A");
    }
}

// 具体产品类B
class ConcreteProductB implements Product {
    public void use() {
        System.out.println("Using B");
    }
}

// 工厂接口
interface Factory {
    Product factoryMethod(String choice);
}

// 具体工厂类
class ConcreteFactory implements Factory {
    public Product factoryMethod(String choice) {
        if (choice == null) {
            return null;
        }
        if (choice.equalsIgnoreCase("A")) {
            return new ConcreteProductA();
        } else if (choice.equalsIgnoreCase("B")) {
            return new ConcreteProductB();
        }
        return null;
    }
}

